<?php

namespace app\common\model;

use think\Model;

class Cate extends Model
{
    public function add($data)
    {
        $validate = new \app\common\validate\Cate();
        if (!$validate->scene('add')->check($data)) {
            return $validate->getError();
        }
        $result = $this->save($data);
        if ($result) {
            return 1;
        }else {
            return '导航添加失败，请重试。';
        }
    }

    public function edit($data)
    {
        $validate = new \app\common\validate\Cate();
        if (!$validate->scene('edit')->check($data)) {
            return $validate->getError();
        }
        $result = $this->isUpdate(true)->save($data);
        if ($result) {
            return 1;
        }else {
            return '导航没有发生变化！';
        }
    }
}
